From 4fe3160cbc7c4e71a85db069186ca26407acba77 Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Mon, 7 Sep 2009 13:49:35 +0100 Subject: [PATCH] vt-d: avoid obtaining iommu->register_lock too early in dma_msi_set_affinity() If set_desc_affinity() fails, the current code doesn't release the spinlock. We should obtain the lock at a later place. Signed-off-by: Dexuan Cui --- xen/drivers/passthrough/vtd/iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/drivers/passthrough/vtd/iommu.c b/xen/drivers/passthrough/vtd/iommu.c index b5131d86df..30370df584 100644 --- a/xen/drivers/passthrough/vtd/iommu.c +++ b/xen/drivers/passthrough/vtd/iommu.c @@ -826,7 +826,6 @@ static void dma_msi_set_affinity(unsigned int irq, cpumask_t mask) struct irq_desc *desc = irq_to_desc(irq); struct irq_cfg *cfg = desc->chip_data; - spin_lock_irqsave(&iommu->register_lock, flags); #ifdef CONFIG_X86 dest = set_desc_affinity(desc, mask); if (dest == BAD_APICID){ @@ -862,6 +861,7 @@ static void dma_msi_set_affinity(unsigned int irq, cpumask_t mask) msg.address_lo |= dest << MSI_TARGET_CPU_SHIFT; #endif + spin_lock_irqsave(&iommu->register_lock, flags); dmar_writel(iommu->reg, DMAR_FEDATA_REG, msg.data); dmar_writel(iommu->reg, DMAR_FEADDR_REG, msg.address_lo); dmar_writel(iommu->reg, DMAR_FEUADDR_REG, msg.address_hi); -- 2.30.2